#ifndef _DevicesSoftIIC_H_
#define _DevicesSoftIIC_H_

#define SORT_IIC_ACK    0
#define SORT_IIC_NACK   1
#define SORT_IIC_BUSY   2
#define SORT_IIC_NORMAL 3

#define SORT_IIC_WRITE_MODE 0x00
#define SORT_IIC_READ_MODE  0x01


typedef struct SoftIICStruct{
    GPIO_Module * SclGPIO;
    GPIO_Module * SdaGPIO;

    uint16_t SclPin;
    uint16_t SdaPin;

    void (* GPIOSetMode) (struct SoftIICStruct *pHandle, uint32_t typeMode);

    void (* GPIOSetHigh) (GPIO_Module* GPIOx, uint16_t Pin);
    void (* GPIOSetLow) (GPIO_Module* GPIOx, uint16_t Pin);

    uint8_t (* GPIOReadBit) (GPIO_Module* GPIOx, uint16_t Pin);

    float delayTime;
}SoftIICHandle;



#define SOFT_IIC_6998_SCK_GPIO_Port     GPIOB
#define SOFT_IIC_6998_SCK_Pin           GPIO_PIN_10

#define SOFT_IIC_6998_SDA_GPIO_Port     GPIOB
#define SOFT_IIC_6998_SDA_Pin           GPIO_PIN_11

#define SOFT_IIC_6998_DELAY_BIT_TIME    2.5f




extern SoftIICHandle g_SoftIIC6988Handle;




int8_t cSoftIICxBusReset(SoftIICHandle *pHandle, int32_t iTime);
void vSoftIICxSetSdaGPIOMode(SoftIICHandle *pHandle, uint32_t typeMode);
int8_t cSoftIICxWriteDatas(SoftIICHandle *pHandle, uint8_t ucAddr, uint8_t ucReg, uint8_t *pucDatas, uint32_t iLength);
int8_t cSoftIICxReadDatas(SoftIICHandle *pHandle, uint8_t ucAddr, uint8_t ucReg, uint8_t *pucDatas, int32_t iLength);



void vSoftIIC6998Init(void);
#define cSoftIIC6998WriteDatas(ucAddr, ucReg, pucDatas, iLength) cSoftIICxWriteDatas(&g_SoftIIC6988Handle, ucAddr, ucReg, pucDatas, iLength)
#define cSoftIIC6998ReadDatas(ucAddr, ucReg, pucDatas, iLength) cSoftIICxReadDatas(&g_SoftIIC6988Handle, ucAddr, ucReg, pucDatas, iLength)


#endif
